<template>
    <page-meta :page-style="pageMetaShow" />
    <SkeletonGood v-if="skeletonLoading" />
    <view v-else>
        <!-- 主图 -->
        <Mainimg :data="state" />
        <!-- 活动状态 -->
        <activityStatus
            v-if="state.activityId && state.activityType !== 7 && state.activityType !== 8"
            :state="state.data"
            @arrive="getDetail" />
        <!-- 标题及分享 -->
        <Title :data="state" :shareAppMessage="shareAppMessage" />
        <!-- 温馨提示 -->
        <propsVue v-if="state.activityId && [3, 4, 5].includes(state.activityType)" :state="state.data" />
        <!-- 拼团列表 -->
        <grouplist
            v-if="[3, 4, 5].includes(state.activityType) && state.activityStatus == 2 && state.gatherGroup == 2"
            :activityId="state.activityId"
            :goodsId="goodsIdArg"
            @opneGroupPopup="opneGroupPopup"
            @openGroupSkupop="openGroupSkupop" />
        <!-- 商品规格 -->
        <Notice
            :data="state"
            :skuInformation="sku_information"
            @openServePopup="onOpenServePopup"
            @openActivityDialog="openActivityDialog"
            @openSkuDialog="openDialog(1)"
            @openCouponDialog="showCouponListVisible = true" />
        <!-- 商品详情 -->
        <detail :state="state.data" />
        <!-- 底部按钮 -->
        <Btngroup :data="state" :cartCount="state.cartCount" :points="state.points" @openSkuDialog="openDialog" />
        <orderPayDia
            v-model="state.orderPayVisible"
            :orderPayTime="state.orderPayTime"
            @confirm="state.onOrderPayConfirm" />
        <groupPopup
            v-model="state.groupPopupShow"
            :activityId="state.activityId"
            :goodsId="goodsIdArg"
            @openGroupSkupop="openGroupSkupop" />
        <GoodEmpty v-if="state.goodEmptyVisible" :text="state.goodEmptyText" />
        <view class="float-box-good">
            <customerServiceFloat v-if="showServiceFloat" />
        </view>
        <uni-popup ref="popup" @change="changesku" :safe-area="false">
            <view class="popup-content">
                <view class="pop_cancel" @click.stop="popup.close()">
                    <img class="pop_logo" :src="getImgOssUrl('/ui-prod-2.0.0/cancel_1.1.png')" />
                </view>
                <skupop
                    :type="state.type"
                    :from="state.from"
                    :points="state.points"
                    :goodsId="goodsIdArg"
                    :shopId="shopIdArg"
                    :activityId="state.activityId"
                    :activityStatus="state.activityStatus"
                    :spellTotalNum="state.surplusNum"
                    :show="show"
                    @updata="updataDetail"
                    @popup="popup.open('bottom')"
                    @close="close"
                    @getskuvalue="getskuvalue"
                    @getSpellNum="getSpellNum"
                    @buyGoods="toConfirm" />
            </view>
        </uni-popup>
        <uni-popup ref="cupopup" @change="change" :safe-area="false">
            <view class="popup-content" style="padding-top: 0">
                <goodCoupon
                    :goodsId="goodsIdArg"
                    @close="hideCouponList"
                    :show="showCouponListVisible"
                    @popup="cupopup.open('bottom')" />
            </view>
        </uni-popup>
        <el-loading></el-loading>
    </view>
    <ServePopup v-model="state.servePopupShow" :params="{ goodsId: goodsIdArg, shopId: shopIdArg }" />
    <ActivityPopup v-model="state.activityPopupShow" :data="state" />
    <!-- 隐私监听 -->
    <el-privacy-listener-popup :is-handle-tab-bar="false"></el-privacy-listener-popup>
</template>
<script setup>
import Mainimg from './mainimg.vue';
import activityStatus from './activityStatus.vue';
import Title from './title.vue';
import propsVue from './props.vue';
import grouplist from './grouplist.vue';
import Notice from './notice.vue';
import detail from './detail.vue';
import Btngroup from './btngroup.vue';
import orderPayDia from './orderPayDia.vue';
import GoodEmpty from '@/components/goodEmpty';
import groupPopup from './groupPopup.vue';
import ActivityPopup from './activityPopup.vue';
import ServePopup from './servePopup.vue';
import SkeletonGood from '@/components/skeletonGood';
import { onShow, onShareAppMessage, onHide, onUnload } from '@dcloudio/uni-app';
import request from '@/request';
import router from '@/router';
import skupop from '@/components/skupop';
import goodCoupon from '@/components/coupon/good';
import customerServiceFloat from '@/components/customerServiceFloat';
import storage from '@/commons/storage';
import { useTrace } from '@/commons/trace';
import { checkToken, getImgOssUrl, throttle, isNotEmpty, isObject } from '@/commons/utils';
import { ref, reactive, computed, inject } from 'vue';
import { getParamsBySceneHook } from '@/hooks';
import { getCorpInfo } from '@/hooks';

const props = defineProps({
    goodsId: { type: Number },
    goodsNo: {},
    shopId: {},
    activityId: {},
    // integral // 积分商品
    from: { type: String },
    // 邀请人id
    inviteMemberId: { type: String },
    channel: { type: [String, Number] },
    scene: { type: String }
});

/** 解决推广二维码传参问题， 从props中直接取值不满足此情况，故引入下面参数 */
let goodsIdArg = ref(0);
let shopIdArg = ref(0);
let activityIdArg = ref(0);
let channel = ref(0);
let inviteMemberId = ref(0);
let fromArg = ref('');

const currency = inject('currency');

const defaultImg = ref(getImgOssUrl('/ui-prod-2.0.0/errorImg.png'));
const { traceStart, traceLoad, traceStay, traceReport } = useTrace({ autoLoad: false });
const popup = ref();
const skeletonLoading = ref(true);
let showCouponListVisible = ref(false);
let show = ref(false);
const showServiceFloat = ref(false);
const sku_information = ref('');
const cupopup = ref();
let goodsDetail = reactive({
    param: {
        goodsSpecList: [],
        skuSepcList: {},
        materialList: [],
        skuList: [],
        specValueList: [],
        goodsDescription: '',
        goodsMaxPrice: 0,
        goodsMinPrice: 0
    }
});
const state = reactive({
    data: {},
    servePopupShow: false, // 服务弹窗
    activityPopupShow: false, // 满减活动弹窗
    currentCoverIndex: 0, //  当前封面图下标
    materialList: [], // 封面图列表
    goodsName: '',
    from: '', // 从哪里来
    minPrice: 0, // 最低价
    maxPrice: 0, // 最高价
    stock: 0,
    onSale: 0, // 商品状态1:上架、2:下架（仓库）、3 售罄
    serviceInfo: '快递发货', // 快递发货｜上门自提
    // 活动商品
    activityId: 0, // 活动id
    activityType: 0, // 活动类型 2秒杀 3普通拼团 4老带新拼团
    activityStatus: '', // 活动状态 1未开始 2 进行中 3已结束
    gatherGroup: 0, // 是否显示拼团列表 2 为开启
    spellGroupNum: 0, // 几人已团
    discountRepeat: 2, // 优惠叠加 1-不叠加 2-叠加
    // 积分商品
    points: 0, // 用户已有积分数
    isPointsGood: true, // 商品是否下架
    type: 1,
    cartCount: 0,
    orderPayVisible: false,
    orderPayTime: '',
    toast: '',
    onOrderPayConfirm: throttle(() => {
        onOrderPayConfirm();
    }, 1000),
    goodEmptyVisible: false,
    goodEmptyText: '',
    groupPopupShow: false,
    spellOrderId: '', //拼团id
    surplusNum: 0, //拼团人数
    // 满减商品
    orderAmount: 0, // 满减商品订单金额
    reduce: 0,
    // discountRepeat 0,
    fullReduceMail: 0,
    activityDesc: ''
});

/* 控制弹窗触摸穿透 */
const pageMetaShow = computed(() => {
    let isShow =
        showCouponListVisible.value ||
        show.value ||
        state.groupPopupShow ||
        state.servePopupShow ||
        state.activityPopupShow;
    return `overflow: ${isShow ? 'hidden' : 'visible'}`;
});
/* 金额 /100 */
const onDivide = (v, num = 100) => currency(v).divide(num).value;

/* 设置 navBar 名称 */
const onSetNav = (title = '商品不存在') => uni.setNavigationBarTitle({ title });

/* 隐藏骨架屏 */
const onSkeletonHide = () => (skeletonLoading.value = false);

/* 商品不存在 */
const onGoodEmpty = (text = '商品不存在') => {
    state.goodEmptyVisible = true;
    state.goodEmptyText = text;
};

// 阶梯拼团
let ladderObj = reactive({
    spellNum: 0 //选择的拼团人数
});
const getskuvalue = data => {
    sku_information.value = data ? `${data}` : `请选择${specValue.value}`;
};
const getSpellNum = ({ num }) => {
    ladderObj.spellNum = num;
};
const specValue = ref();
/* 获取会员信息 */
const getMemberInfo = async () => {
    if (!storage.get('ZW_TENANT_ID') || !storage.get('ZW_CORP_ID')) {
        await getCorpInfo();
    }
    const { data } = await request('memberInfo');
    state.points = onDivide(data.availablePoints);
};
// 获取购物车数量
const getCartCount = async () => {
    const res = await request('cartQuantityServ');
    state.cartCount = res.data.quantity;
};

// 满减
const getActiveMes = () => {
    const { orderAmount, reduce } = state.data.activity.discountSet;
    state.orderAmount = orderAmount;
    state.reduce = reduce;
    state.discountRepeat = state.data?.activity?.discountSet?.discountRepeat;
    state.fullReduceMail = state.data?.activity?.discountSet?.fullReduceMail;
    if (state.activityType === 7) {
        state.activityDesc = `满${onDivide(orderAmount)}元减${onDivide(reduce)}元`;
    } else {
        state.activityDesc = `满${orderAmount}件打${onDivide(reduce, 10)}折`;
    }
};

// 初始化数据
const initData = res => {
    state.from = props.from || fromArg.value;
    state.goodsName = res.goodsName;
    state.stock = res.goodsStock;
    state.onSale = res.onSale;
    state.materialList = res.materialList || [];
    state.currentCoverIndex = state.materialList.findIndex(item => item?.isCover === 1);
    state.currentCoverIndex = state.currentCoverIndex === -1 ? 0 : state.currentCoverIndex;

    state.minPrice = onDivide(res.goodsMinPrice);
    state.maxPrice = onDivide(res.goodsMaxPrice);
    if (state.onSale != 2) {
        state.activityId = activityIdArg.value || res.activity?.id;
    }
    state.activityType = res.activity?.activityType;
    state.activityStatus = res.activity?.activityStatusName.realStatus;
    state.activityStartTime = res.activity?.activityStartTime;
    state.activityEndTime = res.activity?.activityEndTime;
    state.gatherGroup = res.activity?.spellActivityGroupInfo?.gatherGroup;
    state.spellGroupNum = res.activity?.spellGroupNum;
    state.isPropReduce = res.isPropReduce;
    state.serviceInfo = res.serviceInfo;
    // 秒杀
    if (state.activityType == 2) {
        let sortArr = res.activity.activityGoods.sort((a, b) => a.spikePrice - b.spikePrice);
        state.minPrice = onDivide(sortArr[0].spikePrice);
        state.maxPrice = onDivide(sortArr[sortArr.length - 1].spikePrice);
        state.stock = res.activity.activityGoods.reduce((pre, cur) => pre + +cur.spikeStockSurplus, 0);
    }
    // 拼团
    if ([3, 4, 5].includes(state.activityType)) {
        let sortArr = res.activity.spellActivityPrice.sort((a, b) => a.spellPrice - b.spellPrice);
        state.minPrice = currency(sortArr[0].spellPrice).divide(100).value;
        state.maxPrice = currency(sortArr[sortArr.length - 1].spellPrice).divide(100).value;
    }
    // 满减
    if ([7, 8].includes(state.activityType)) {
        getActiveMes();
    }
    // 如果库存为空状态变成已售罄
    if (state.onSale != 2 && state.stock === 0) {
        state.onSale = 3;
    }
    // 积分商品;
    if (state.from === 'integral') {
        state.isPointsGood = res.isPointsGood;
        let sortArr = res.skuList
            .filter(item => item.consumerPoints !== null)
            .sort((a, b) => a.consumerPoints - b.consumerPoints);
        let PointArr = res.skuList
            .filter(item => item.skuPrice !== null && item.money !== null && item.consumerPoints !== null)
            .sort((a, b) => a.skuPrice - b.skuPrice);

        // 积分
        state.minPrice = onDivide(sortArr[0].consumerPoints);
        state.maxPrice = onDivide(sortArr[sortArr.length - 1].consumerPoints);
        // 金额
        state.minPoint = onDivide(PointArr[0].money);
        // 积分
        state.minPrice = onDivide(PointArr[0].consumerPoints);
        state.stock = sortArr.reduce((pre, cur) => pre + +cur.skuStock, 0);
    }
};
// 重新加载商品详情数据(使用场景：当商品售罄、下架)
const updataDetail = () => {
    getDetail();
};
// 获取商品详情数据
const getDetail = async () => {
    let params = {
        goodsId: goodsIdArg.value,
        shopId: storage.get('ZW_SHOP_ID')
    };
    if (isNotEmpty(activityIdArg.value)) {
        params.activityId = activityIdArg.value;
    }
    if (props.from === 'integral' || fromArg.value == 'integral') {
        params.isPointsGood = 1;
    }
    try {
        const res = await request('goodsDetailServ', params);
        // 商品被删除或者积分商品被删除
        if (!isNotEmpty(res.data) || !res.data.skuList.length) {
            onSetNav();
            onGoodEmpty();
            onSkeletonHide();
            return;
        }
        Object.assign(state, res);
        state.data = res.data;
        // 活动被删除
        if (state.activityId && !res.data.activity) {
            onSetNav('活动不存在');
            onGoodEmpty('活动不存在');
        }
        // 商品下架
        if (res.data.onSale === 2) {
            delete res.data.activity;
            state.activityId = 0;
        }
        initData(res.data);
        state.activityType = res.data.activity?.activityType;
        if ([3, 4, 5].includes(state.activityType)) {
            state.data.activity.goodsMinPrice = res.data.goodsMinPrice;
            state.discountRepeat = res.data.activity.spellActivityGroupInfo.discountRepeat;
        }
        traceReport('visit_page_product_detail', { productId: res.data.goodsId, productName: res.data.goodsName });
        goodsDetail.param = Object.assign(goodsDetail.param, res.data);
        goodsDetail.param.goodsSpecList.sort((a, b) => {
            return a.sort - b.sort;
        });

        // 阶梯拼团
        if (state.activityType == 5) {
            ladderObj.allThreeSpeArr = res.data?.activity?.spellActivityPrice || [];
            state.minPrice = currency(res.data?.activity?.spellActivityGroupInfo?.minPrice).divide(100).value;
            state.maxPrice = currency(res.data?.activity?.spellActivityGroupInfo?.maxPrice).divide(100).value;
            // 阶梯拼团取最大人数
            state.data.activity.spellActivityGroupMixNum = res.data?.activity?.spellActivityGroupInfo?.maxRequiredNum;
        }

        specValue.value = goodsDetail.param.goodsSpecList.map(item => item.attributeKey).join(';');
        sku_information.value = `请选择${specValue.value}`;
        // 单规格商品
        if (goodsDetail.param.specType === 1) {
            sku_information.value = '请选择单规格';
        }

        if (props.from === 'integral' || fromArg.value === 'integral') {
            if (res.data.isDeleted) {
                onSetNav();
                onGoodEmpty();
                onSkeletonHide();
                return;
            } else {
                onSetNav('积分兑换');
            }
        } else {
            onSetNav(state.goodsName);
        }
        onSkeletonHide();
    } catch (error) {
        onSetNav('商品详情');
        onSkeletonHide();
        if (!isObject(error)) return;
        uni.showToast({
            title: error.data.msg,
            icon: 'none',
            duration: 2000
        });
    }
};

// 获取商品优惠券
const getCoupon = async () => {
    let params = {
        goodsId: goodsIdArg.value,
        userId: storage.get('userId') || 0,
        shopId: storage.get('ZW_SHOP_ID'),
        pageSize: 5,
        pageNum: 1
    };
    const res = await request('queryGoodCouponListServ', params);
    state.couponContent = String(Array.from(res.data?.list || [], x => x.couponTitle)).replaceAll(',', ';');
};

const defineQueryParams = query => {
    inviteMemberId.value = query.inviteMemberId;
    channel.value = query.channel;
    goodsIdArg.value = query.goodsId;
    shopIdArg.value = query.shopId || storage.get('ZW_SHOP_ID');
    activityIdArg.value = query.activityId;
    fromArg.value = query.from;
};

/* 满减活动详情弹窗-打开 */
const openActivityDialog = () => {
    state.activityPopupShow = true;
};

// 满减活动详情弹窗-确认
const onActivityPopupConfirm = () => {
    state.activityPopupShow = false;
    router.push({
        path: '/pages-cart/activeDetail/index',
        query: {
            activityId: state.data.activity.id
        }
    });
};
/* 服务弹框 */
const onOpenServePopup = () => {
    state.servePopupShow = true;
};

onShow(async () => {
    userId.value = storage.get('userId');
    traceStart();
    const islogin = await checkToken();
    // 不同店铺过来切店以保证后续逻辑正常
    if (props.shopId > 0 && props.shopId != storage.get('ZW_SHOP_ID')) {
        storage.set('ZW_SHOP_ID', Number(props.shopId));
    }
    let queryParams = props;
    if (props.scene) {
        const res = await getParamsBySceneHook(props.scene);
        queryParams = res;
    }
    defineQueryParams(queryParams);

    if (
        (props.inviteMemberId > 0 && props.channel == 2) ||
        (queryParams.inviteMemberId > 0 && queryParams.channel == 2)
    ) {
        // queryParams二维码生成的inviteMemberId
        if (islogin) {
            request('bindInventIdServ', { distributorId: props.inviteMemberId || queryParams.inviteMemberId });
        } else {
            storage.set('inviteMemberId', Number(props.inviteMemberId || queryParams.inviteMemberId));
            storage.set('channel', Number(props.channel || queryParams.channel));
        }
    }
    /** 商品积分逻辑 */
    (props.from === 'integral' || fromArg.value === 'integral') && islogin && getMemberInfo();
    /** 购物车左上角角标逻辑 */
    islogin && getCartCount();
    getDetail();
    getCoupon();
    hasCustomerService();
});

/**
 * 客服入口
 */
const hasCustomerService = async () => {
    let res = await request('openServer');
    storage.set('openServerMes', JSON.stringify(res.data));
    showServiceFloat.value = res.data.goodsDetail === 2;
};
onHide(() => {
    traceStay();
});

onUnload(() => {
    traceStay();
});

const close = () => {
    popup.value.close();
    getCartCount();
};

// 是否有未支付订单
const getIsOrderPay = () => {
    let params = {
        activityId: state.activityId,
        goodsId: goodsIdArg.value
    };
    return request('isPayOrderServ', params);
};

// 待支付弹框确认
const onOrderPayConfirm = () => {
    let query = {
        orderId: state.orderPayData.orderId,
        activityId: state.activityId
    };
    router.push({
        path: '/pages-user/orderdetail/index',
        query
    });
};

// 打开弹框
const openDialog = async data => {
    if (state.data?.activity?.id && state.data?.activity?.activityType == 2) {
        // 秒杀商品
        if (state.stock == 0) {
            uni.showToast({
                title: '商品已售罄',
                icon: 'none',
                duration: 3000
            });
            return;
        }
    } else {
        if (state.onSale === 2 || state.onSale === 3) {
            uni.showToast({
                title: state.onSale === 2 ? '商品已下架' : '商品已售罄',
                icon: 'none',
                duration: 3000
            });
            return;
        }
    }

    // 点击加购或立即购买校验token
    if (!(await checkToken())) {
        router.push('/pages-user/login/index');
        return;
    }
    if (props.from === 'integral' || fromArg.value === 'integral') {
        state.type = 1;
        show.value = true;
        return;
    }
    if (state.activityType == 2) {
        state.type = 2;
        if (state.activityStatus == 1) {
            show.value = true;
            return;
        }
        try {
            await getIsOrderPay();
        } catch (error) {
            if (error.data.code == 3000017) {
                state.orderPayData = error.data.data;
                state.orderPayTime = error.data.data.cancelAt;
                state.orderPayVisible = true;
                return;
            } else if (error.data.code == 3000018) {
                uni.showToast({
                    title: error.data.msg,
                    icon: 'none',
                    duration: 3000
                });
                return;
            } else {
                uni.showToast({
                    title: error.data.msg,
                    icon: 'none',
                    duration: 3000
                });
            }
        }
    }
    // 单独购买
    if (data == 8) {
        state.type = 1;
        show.value = true;
        return;
    }
    // 发起拼团
    if (data == 9) {
        state.type = 3;
        show.value = true;
        return;
    }
    if (data == 1) {
        // popup.value.open('bottom');
        show.value = true;
    } else if (data == 2) {
        if (goodsDetail.param.onSale != 1) return;
        if (goodsDetail.param.onSale == 1) {
            show.value = true;
        }
    } else {
        show.value = true;
    }
};

// 参团校验
const getIsGroupStatus = spellOrderId => {
    return request('getOffereCheckGroupServ', { spellOrderId });
};
const openGroupSkupop = async v => {
    try {
        const res = await getIsGroupStatus(v.spellOrderId);
    } catch (error) {
        if (error.data.code == 4000006) {
            uni.showToast({
                title: error.data.msg,
                icon: 'none',
                duration: 3000
            });
            return;
        } else {
            uni.showToast({
                title: error.data.msg,
                icon: 'none',
                duration: 3000
            });
        }
    }
    state.type = 3;
    state.spellOrderId = v.spellOrderId;
    state.surplusNum = v.requiredNum;
    show.value = true;
};

const toConfirm = async val => {
    let { quantity, skuId } = val;
    let goodsId = +goodsIdArg.value;
    // 积分商品
    if (state.from === 'integral') {
        let query = {
            skuList: JSON.stringify([{ goodsId, quantity, skuId, isPointsGood: 1 }]),
            orderType: 6 // 积分商品 type 待定
        };
        router.push({
            path: '/pages-cart/confirm/index',
            query
        });
        return;
    }
    let query = {
        skuList: JSON.stringify([{ goodsId, quantity, skuId }]),
        orderType: 1
    };
    // type 1普通 2秒杀 3拼团
    if (state.type != 1) {
        if (state.activityType == 2) {
            if (state.activityId && state.activityStatus != 1) {
                query.activityId = state.activityId;
                query.orderType = 2;
                try {
                    await getIsOrderPay();
                } catch (error) {
                    if (error.data.code == 3000017) {
                        state.orderPayData = error.data.data;
                        state.orderPayTime = error.data.data.cancelAt;
                        state.orderPayVisible = true;
                        return;
                    } else {
                        uni.showToast({
                            title: error.data.msg,
                            icon: 'none',
                            duration: 3000
                        });
                    }
                }
            }
        }
        if ([3, 4, 5].includes(state.activityType) && state.type == 3) {
            query.activityId = state.activityId;
            query.orderType = 3;
            query.spellNum = state.data.activity.spellActivityGroupMixNum;
            // 阶梯拼团 (好像不走这里？)
            if (state.activityType === 5) {
                query.spellNum = ladderObj.spellNum;
            }
            if (state.spellOrderId) {
                query.spellOrderId = state.spellOrderId;
                query.spellNum = state.surplusNum;
            }
        }
    }
    router.push({
        path: '/pages-cart/confirm/index',
        query
    });
};

// 生成分享配置
let userId = ref(storage.get('userId'));
const shareAppMessage = computed(() => {
    const shopId = storage.get('ZW_SHOP_ID');
    const imageUrl = state?.data?.materialList?.filter(item => item.isCover == 1);
    let data = {
        title: '你的好友给您发来了超划算商品，快来看看吧！',
        path: `/pages-cart/good/index?goodsId=${state.data.goodsId}&goodsNo=${state.data.goodsNo}&shopId=${shopId}`,
        imageUrl: imageUrl?.[0]?.materialSrc || state?.data?.materialList?.[0]?.materialSrc
    };
    // data.path += `&inviteMemberId=${props.inviteMemberId || inviteMemberId.value}&channel=${
    //     props.channel || channel.value
    // }`;
    data.path += `&inviteMemberId=${userId.value}&channel=2`;
    if (state.activityType == 2) {
        data.title = `【限时秒杀，仅需${
            currency(state.data.activity.activityGoods[0].spikePrice).divide(100).value
        }元】${state.data.goodsName}`;
        data.path += `&activityId=${state.activityId}`;
    }
    if ([3, 4, 5].includes(state.activityType)) {
        data.title = `【${state.data.activity.spellActivityGroupMixNum}人团，仅需${
            currency(state.data.activity.spellActivityGroupInfo.minPrice).divide(100).value
        }元】${state.data.goodsName}`;
        data.path += `&activityId=${state.activityId}`;
    }
    if (props.from == 'integral' || fromArg.value == 'integral') {
        data.path += '&from=integral';
    }
    return data;
});
//商品分享
// onShareAppMessage(res => shareAppMessage.value);
// 查看更多拼团
const opneGroupPopup = () => {
    state.groupPopupShow = true;
};

/**
 * 隐藏领券弹框
 */
const hideCouponList = () => {
    cupopup.value.close();
    showCouponListVisible.value = false;
};

/**
 * 监听领券弹框显示状态
 */
const change = type => {
    showCouponListVisible.value = type.show;
};

const changesku = type => {
    show.value = type.show;
    if (!show.value) {
        // 清空选中的拼团id
        state.type = 1;
        state.spellOrderId = '';
        state.surplusNum = '';
    }
};
const imageError = index => {
    goodsDetail.param.materialList[index].materialSrc = defaultImg.value;
};
</script>
<style lang="scss" scoped src="./index.scss"></style>
